﻿using System.Diagnostics;

namespace ThreadPoolTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            ThreadPool.SetMinThreads(6, 6);
            ThreadPool.SetMaxThreads(10, 10);

            Stopwatch watch = new Stopwatch();
            watch.Start();

            void callback(object index)
            {
                Console.WriteLine(String.Format("{0}: Task {1} started", watch.Elapsed, index));
                Thread.Sleep(10000);
                Console.WriteLine(String.Format("{0}: Task {1} finished", watch.Elapsed, index));
            }

            for (int i = 0; i < 20; i++)
            {
                ThreadPool.QueueUserWorkItem(callback, i);
            }

            Console.ReadKey();
        }
    }
}